package com.zy.controller;

import com.zy.pojo.User;
import com.zy.service.CrudService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/crud")
public class UserController {

    @Autowired
    @Qualifier("userServiceImpl")
    CrudService crudService;


    @RequestMapping("/add")
    int add(User user){
        System.out.println("controller"+user.toString());
        return crudService.add(user);
    }
    @RequestMapping("/delete")
    int delete(int id){
        return crudService.delete(id);
    }
    @RequestMapping("/update")
    int update(User user){
        return crudService.update(user);
    }
    @RequestMapping("/select")
    User queryById(int id){
        return crudService.queryById(id);
    }
    @RequestMapping("/selectAll")
    List<User> queryAll(){
        return crudService.queryAll();
    }
}
